<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  propupdate.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.20  $
  '  $Date:   19 Nov 1999 11:41:46  $
  '  $Author:   shsieh  $
  '  $Workfile:   propupdate.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->

<%
Dim SubmittedValues(256)
Dim ValidationStatus(256)

'This property page can be used for Folder or Document, depending on the Type value
'passed in.
'For folder, the Ident is the folder's pathname.
'For document, the Ident is the document's ID.
ObjType = CInt(Request.Form("IDMWeb_ObjType"))
Ident = Request.Form("IDMWeb_Ident")

'Is the user trying to do an update ? Or just validation ?
Update = Request.Form("UpdateFlag")

'Keep track of whether the user prefers to display the property hints during this session.
if Request.Form("ShowHints") = "on" then
    Session("ShowHints") = 1
else
    Session("ShowHints") = 0
end if


'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
'whether the user has logged on.
'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
LibraryLogonID = Session("LibraryLogonID")
set LibraryObj = Server.CreateObject("IDMObjects.Library")
LibraryObj.LogonID = LibraryLogonID


'Get the corresponding document or folder object as specified by ObjType and Ident.
set FObj = LibraryObj.GetObject(ObjType, Ident)

'Get the object's Permissions.
set Permissions = FObj.Permissions

'Get the object's Properties.
set Props = FObj.Properties

Status = "0"

'Permissions
for i=1 to Permissions.Count
    set Permission = Permissions.Item(i)
    Permission.GranteeName = Request.Form(CStr(Permission.ID))
next

'Properties
for i=1 to Props.Count
    set prop = Props(i)
    set PropDesc = prop.PropertyDescription

    if PropDesc.GetExtendedProperty("F_ISREADONLY") then
        'Ingnores read-only property value submitted.
        SubmittedValues(i) = ""
        ValidationStatus(i) = ""
    elseif IsNull(prop.Value) and Request.Form(prop.Name) = "" then
        'Ingnores empty property value submitted.
        SubmittedValues(i) = ""
        ValidationStatus(i) = ""
    elseif prop.Name = "F_CLOSED" then
        if Props("F_RETENTBASE") or Request.Form("F_RETENTBASE") then
            'If the Retention Base is based on Entry Date, then ignores the Closed setting.
            SubmittedValues(i) = ""
            ValidationStatus(i) = ""
        else
            value = Request.Form(prop.Name)
            SubmittedValues(i) = value
            On Error Resume Next
            prop.Value = value
            if Len(Err.Description) = 0 then
                'The property assignment is valid.
                ValidationStatus(i) = "1"
            else
                'Property assignment failed.
                Status = "-1"
                ValidationStatus(i) = "-1"
            end if
        end if
    else
        value = Request.Form(prop.Name)
        SubmittedValues(i) = value
        if PropDesc.GetState(Application("idmChoice")) then
            value = CInt(value)
        end if

        'Assign the submitted property value to see whether it's valid or not.  
        On Error Resume Next
        prop.Value = value
        if Len(Err.Description) = 0 then
            'The property assignment is valid.
            ValidationStatus(i) = "1"
        else
            'Property assignment failed.
            Status = "-1"
            ValidationStatus(i) = "-1"
        end if
    end if
next

'Keep track of submitted values and validation status.
Session("SubmittedValues") = SubmittedValues
Session("ValidationStatus") = ValidationStatus


'If the user is trying to do an update and all submitted values passed validation.
if Update and (not Status) then
    On Error Resume Next
    FObj.Save
    if Len(Err.Description) > 0 then
        Status = "-1"
    else
        Status = "1"
    end if
end if


'Redirect back to the property page to display status of the update or validation appropriately.
Response.Redirect "propcontent.asp?Type=" + CStr(ObjType) + "&Ident=" + Ident + "&Update=" + Update + "&Status=" + Status
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html">
<TITLE>Property Update</TITLE>
</HEAD>

<body bgcolor="#FFFFFF">

<%= ObjType %><br>
<%= Ident %><br>

<% for each p in Request.Form %>
    <%= p %> = <%= Request.Form(p) %><br>
<% next %>

</BODY>
</HTML>
